package org.example.coffeeshoporderingsystem.member.service.impl;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.example.coffeeshoporderingsystem.common.service.impl.BaseServiceImpl;
import org.example.coffeeshoporderingsystem.member.dao.MemberDAO;
import org.example.coffeeshoporderingsystem.member.dto.MemberDTO;
import org.example.coffeeshoporderingsystem.member.entity.Member;
import org.example.coffeeshoporderingsystem.member.service.MemberService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Service
@Transactional
public class MemberServiceImpl extends BaseServiceImpl<Member, MemberDAO> implements MemberService {
    @Override
    public PageInfo<Member> findPageByMemberDTO(int pageNo, MemberDTO memberDTO) {
        PageHelper.startPage(pageNo,5) ;
        List<Member> memberList ;
        if (memberDTO==null || "".equals(memberDTO.getName())){
            memberList = baseDAO.selectAll();
        }else{
            memberList = baseDAO.selectByMemberDTO(memberDTO);
        }
        return PageInfo.of(memberList);
    }
}
